
import { IController } from '../interface/IController.interface';
import { Router, Request, Response, NextFunction as NF } from 'express'
import {AController} from '../abstract/AController.abstract'
export class PostController extends AController implements IController {
    // 这个字段是一个public(公共接口)的类型，他是express.Router
    // 约束path
    protected path = "/posts"
    public router: Router;

    constructor() {
        super()
        this.router = Router()
        this.attachToRoutes()
    }
    private attachToRoutes() {
        const path = this.path;
        this.router.get(path, this.getPosts)
    }
    // 这是一个示例接口，返回很多帖子
    private getPosts(req: Request, res: Response, next: NF) {
        res.send("你好世界！！！！！！！！！！！！！！！")
    }
}